<#assign pojo=oneToManyPojo.getOne()>
<#assign many=oneToManyPojo.getMany()>
<#assign ones=oneToManyPojo.getOnes()>
<#assign fields=pojo.getFilterdPojoFields()>
<#assign declarationName = pojo.importType(pojo.getDeclarationName())>
<#assign declarationNameFirstLetterLower = pojo.importType(pojo.getDeclarationNameFirstLetterLower())>
<#assign realPackageAndClassPath = "${pojo.getRealPackageAndClassPath()}">
<#assign masterid = pojo.getDeclarationNameFirstLetterLower()+"Id">
import React from 'react'
import PropTypes from 'prop-types'
import {Form, Radio, Modal, Button, Row, Col, DatePicker, Input, Cascader, Switch, Icon, Affix, InputNumber} from 'antd'

const {RangePicker} = DatePicker
const FormItem = Form.Item;

import ${declarationName}Form from '../components/${declarationName}Form'

const formItemLayout = {
  labelCol: {
    span: 6,
  },
  wrapperCol: {
    span: 14,
  },
}

const modal = ({
                 item = {},
                 onOk,
                 form: {
                   getFieldDecorator,
                   validateFields,
                   getFieldsValue,
                 },
                 ...modalProps
               }) => {
  function handleOk() {
    validateFields((errors) => {
      if (errors) {
        return
      }
      const data = {
        ...getFieldsValue(),
        key: item.key,
      }
      onOk(data)
    })
  }

  const modalOpts = {
    ...modalProps,
    onOk: handleOk,
  }

  const ${declarationNameFirstLetterLower}FormProps = {
    item: item,
  }

  return (
    <Modal {...modalOpts}>
<#assign fields=pojo.getFilterdPojoFields()>
<#foreach field in fields>
    <#if field.getIsSampleField()>
        <FormItem label="<#if field.getComment()?exists>${field.getComment()}<#else>${field.getName()}</#if>" hasFeedback {...formItemLayout}>
          {getFieldDecorator('${field.getName()}', {
            initialValue: item.${field.getName()},
            rules: [
              {
                //required: true,
              },
            ],
          })(<Input />)}
        </FormItem>
    </#if>
</#foreach>
    </Modal>
  )
}

modal.propTypes = {
  form: PropTypes.object.isRequired,
  type: PropTypes.string,
  item: PropTypes.object,
  onOk: PropTypes.func,
}

export default Form.create()(modal)